/** @type {import('next').NextConfig} */
const path = require("path");

const nextConfig = {
  transpilePackages: ['antd-mobile'],
  distDir: "build",
  env: {
    API_BASE_URL: process.env.API_BASE_URL,
  },
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      use: ["@svgr/webpack"],
    }); // 针对 SVG 的处理规则
    config.resolve.alias["@"] = path.resolve(__dirname);
    return config;
  },
  async rewrites() {
    return [
      {
        source: "/api/:path*",
        destination: "http://192.168.19.23:8023/:path*",
      },
    ];
  },
};

if (process.env.DOCKER) {
  nextConfig.output = "standalone";
}

module.exports = nextConfig;
